import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import KnowView from '../views/KnowView.vue'
import LogView from '../views/log.vue'
import MemberView from '../views/MemberView.vue'
import adminRouter from './adminRoutes.js'

// 主应用路由
const mainRoutes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/AboutView.vue'),
  },
  {
    path: '/know',
    name: 'know',
    component: KnowView,
  },
  {
    path: '/log',
    name: 'log',
    component: () => import('../views/log.vue'),
  },
  {
    path: '/areasort',
    name: 'areasort',
    component: () => import('../views/areasort.vue'),
  },
  {
    path: '/hobby',
    name: 'hobby',
    component: () => import('../views/hobby.vue'),
  },
  {
    path: '/food',
    name: 'food',
    component: () => import('../views/food.vue'),
  },
  {
    path: '/share',
    name: 'share',
    component: () => import('../views/share.vue'),
  },
  {
    path: '/member',
    name: 'member',
    component: MemberView,
  },
];

// 创建主路由实例
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...mainRoutes, ...adminRouter.options.routes]
});

// 导出主路由
// 注意：adminRouter的守卫已经在其自身文件中配置
export default router
